//
//  HSQLManager.h
//  HMusicPlayer
//
//  Created by Hament on 14/9/5.
//  Copyright (c) 2014年 HJ. All rights reserved.
//

#import <Foundation/Foundation.h>

@class HPlaylistItem,FMDatabase,HSongItem;
@interface HSQLManager : NSObject
@property (nonatomic,strong) FMDatabase * songDB ;


#pragma mark singleon
+(HSQLManager *)shareSqlMg;

-(BOOL)openSongDB;
-(BOOL)closeSongDB;

-(void)beginTransactionSongDB;
-(void)commitSongDB;

//------------通用---------
//从表中删除纪录
+(BOOL)deleteRecordIntable:(NSString*)tablename andID:(NSString*)recordID;
//从表中根据精确条件删除
+(BOOL)deleteRecordIntable:(NSString*)tablename WithDic:(NSDictionary*)paraDic;




#pragma  mark -------------查询---------
//获取db记录的版本号
+(NSString*)getappVersionInDB;

//获取自定义播放列表
+(NSMutableArray*)getPlayListFromSongDB;

//获取个歌曲
+(NSMutableArray*)getSongsByPlaylistItem:(HPlaylistItem*)pitem;

//寻找like的歌曲是否有来自itunes的,因为之前某些结果被group by掉
+(BOOL)findLikeSongsisFromItunes:(HSongItem*)songitem;

//获取歌曲的歌词路径
+(NSString*)getLyricPathWithSongItem:(HSongItem*)songItem;

#pragma  mark -------------插入---------

//插入playlist
+(void)insertPlaylist:(HPlaylistItem*)pitem songs:(NSArray*)arr;//array为hplaylistitem

//批量插入播放列表下的歌曲
+(void)batchInsertSongsWithPlaylist:(HPlaylistItem*)pitem songs:(NSArray*)arr;

//批量插入播放列表下的歌曲
+(void)batchInsertSongsWithPlaylist:(HPlaylistItem*)pitem songs:(NSArray*)arr db:(id)db;

//插入歌曲信息,歌词
+(void)insertSonginfoWithSongItem:(HSongItem*)songitem andInfo:(NSDictionary*)dic;

#pragma  mark -------------更新---------

//更改app版本号

//更新playlist
+(BOOL)updatePlaylistWithItem:(HPlaylistItem*)pitem;
///更新歌的名称
+(BOOL)updateSongNameWithItem:(HSongItem*)sitem;
//更新歌的收藏
+(BOOL)updateLikeStateWithItem:(HSongItem*)sitem;

//更新歌的名称,用于itunes的修改同步到数据库
+(BOOL)updateSongName:(NSString*)name path:(NSString*)newpath oldPath:(NSString*)oldpath;

//批量删除歌曲
+(void)batchDeleteSongsWithSongItems:(NSArray*)arr;

//更新sandbox的urldata
+(void)updateBookmakrDataWithSongItem:(HSongItem*)songitem;
#pragma  mark -------------删除---------

//删除播放列表+旗下的歌曲
+(BOOL)deletePlaylistWithItem:(HPlaylistItem*)pitem;
//批量删除歌曲-根据歌曲路径
+(void)batchDeleteSongsHasPathWithSongItems:(NSArray*)arr;

//批量删除歌曲

//删除歌曲歌词信息
+(void)removeThelyricInfoWithSongItem:(HSongItem*)songitem;
@end
